package com.ruoyi.web.controller.teacher;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.BasisAntenna;
import com.ruoyi.service.IBasisAntennaService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 天线Controller
 * 
 * @author wangzebing
 * @date 2025-05-16
 */
@RestController
@RequestMapping("/antenna")
public class BasisAntennaController extends BaseController
{
    @Autowired
    private IBasisAntennaService basisAntennaService;

    /**
     * 查询天线列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BasisAntenna basisAntenna)
    {
        startPage();
        List<BasisAntenna> list = basisAntennaService.selectBasisAntennaList(basisAntenna);
        return getDataTable(list);
    }

    /**
     * 导出天线列表
     */
    @Log(title = "天线", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BasisAntenna basisAntenna)
    {
        List<BasisAntenna> list = basisAntennaService.selectBasisAntennaList(basisAntenna);
        ExcelUtil<BasisAntenna> util = new ExcelUtil<BasisAntenna>(BasisAntenna.class);
        util.exportExcel(response, list, "天线数据");
    }

    /**
     * 获取天线详细信息
     */
    @GetMapping(value = "/{antennaId}")
    public AjaxResult getInfo(@PathVariable("antennaId") Long antennaId)
    {
        return success(basisAntennaService.selectBasisAntennaByAntennaId(antennaId));
    }

    /**
     * 新增天线
     */
    @Log(title = "天线", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BasisAntenna basisAntenna)
    {
        basisAntenna.setType("天线");
        return toAjax(basisAntennaService.insertBasisAntenna(basisAntenna));
    }

    /**
     * 修改天线
     */
    @Log(title = "天线", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BasisAntenna basisAntenna)
    {
        return toAjax(basisAntennaService.updateBasisAntenna(basisAntenna));
    }

    /**
     * 删除天线
     */
    @Log(title = "天线", businessType = BusinessType.DELETE)
	@DeleteMapping("/{antennaIds}")
    public AjaxResult remove(@PathVariable Long[] antennaIds)
    {
        return toAjax(basisAntennaService.deleteBasisAntennaByAntennaIds(antennaIds));
    }


    //配置天线
    @PostMapping("/configBasisAnteen")
    public AjaxResult addBasisLoadingUavCamp(@RequestBody BasisAntenna basisAntenna)
    {
        return toAjax(basisAntennaService.addBasisPositionAntenna(basisAntenna));
    }
}
